<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Driving_List extends Page
{
       public $JTJavaScript1 = null;
       public $imgBack = null;
       public $imgAdd = null;
       public $lblempname = null;
       public $lblempid = null;
       public $lblyear = null;
       public $Label48 = null;
       public $hiddenEmp = null;
       public $JTSiteTheme1 = null;
       public $JTDrivingList = null;
       public $Image1 = null;
       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back.png"
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back2.png"
       <?php

       }

       function imgAddJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new.png"
       <?php

       }

       function imgAddJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAdd'].src="image/add_new_blue.png"
       <?php

       }

       function Driving_ListCreate($sender, $params)
       {
       $emp_id = $_GET['emp'];
       $this->hiddenEmp->setValue($emp_id);

       $query_emp = "select * from employee_tbl where autoid='".$this->hiddenEmp->getValue()."'";
       $result_emp = mysql_query($query_emp)or die(mysql_error());
       $row_emp = mysql_fetch_array($result_emp);

       $this->lblempid->Caption=$row_emp['emp_id'];
       $this->lblempname->Caption=$row_emp['lname'].','.$row_emp['fname'];

       $this->imgAdd->setLink('personnel_driving_create.php?emp='.$this->hiddenEmp->getValue());
       $this->imgBack->setLink('personnel_list.php?emp='.$this->hiddenEmp->getValue());
       }

       function JTDrivingListShow($sender, $params)
       {
       $query1 = "select * from emp_drivinghistory_tbl where company_id='".$_SESSION['company_id']."' and emp_id='".$this->hiddenEmp->getValue()."'";
       $result = mysql_query($query1)or die(mysql_error());

        $arr = array();
        while($row = mysql_fetch_array($result))
          {
            $history_id = $row['history_id'];
            $emp = $this->hiddenEmp->getValue();
            $date = "<a href=personnel_driving_edit.php?emp=".$emp."&driving_history=".$history_id.">".$row['date']."</a>";
            $tools = "<img onclick=js_deleteDrive('".$emp."','".$history_id."'); src='image/delete.png' title='delete'>";

            $arr[] = array(
                        'Date' => $date,
                        'Type' => $row['type'],
                        'Description' => $row['description'],
                        'Tools'=>$tools
                        );


          }

            $this->JTDrivingList->setCellData($arr);


       }


}

global $application;

global $Driving_List;

//Creates the form
$Driving_List=new Driving_List($application);

//Read from resource file
$Driving_List->loadResource(__FILE__);

//Shows the form
$Driving_List->show();

?>